﻿using Microsoft.IdentityModel.Tokens;
using QRCodeBluetooth.DAL;
using QRCodeBluetooth.Models;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

namespace QRCodeBluetooth.BUS
{
    public class OwnerBUS
    {
        public ResponseMessage AddOwner(OwnerInfo ownerInfo)
        {
            ResponseMessage message = new ResponseMessage();
            OwnerDAL da = new OwnerDAL();
            int ownerid = da.QueryOwner(ownerInfo.identityInf);
            if (ownerid > 0)
            {
                message.errcode = 1;
                message.errmsg = "该用户已注册，请勿重复注册";
            }
            else
            {
                bool result = da.AddOwner(ownerInfo);
               
                if (result)
                {
                    message.errcode = 0;
                }
                else
                {
                    message.errcode = 1;
                    message.errmsg = "用户注册失败";
                }
            }

            return message;
        }
    }


}
